<style lang="scss" scoped>
.scroll-Y {
  position: relative;
  height: calc(100vh - 50px);
  padding: 0 1rem;
  box-sizing: border-box;
  padding-bottom: 1rem;
}
</style>
<template>
  <view class="">
    <u-navbar back-text="" :title="data.title"></u-navbar>
    <scroll-view scroll-y="true" class="scroll-Y">
      <u-parse :html="agreementContent"></u-parse>
    </scroll-view>
  </view>
</template>

<script setup lang="ts">
import { reactive, ref } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import { getPolicy } from "@/api/app";

let agreementType = ref(""); // 协议类型
const agreementContent = ref(""); // 协议内容
const data = reactive({
  title: "",
});
const getData = async (type) => {
  const res = await getPolicy({ type });
  agreementContent.value = res.content;
  uni.setNavigationBarTitle({
    title: String(res.title),
  });
  uni.hideLoading();
};

onLoad((options: any) => {
  if (options.type) {
    uni.showLoading({
      title: "加载中...",
    });
    agreementType = options.type;
    data.title = options.type == 1 ? "服务协议" : "隐私政策";
    getData(agreementType);
  }
});
</script>
